﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class exame2_boomer_hp : MonoBehaviour
{
    public int hp = 100;
    public GameObject deadReplaceObj;
    public GameObject boomFx;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (hp <= 0)
        {
            if (deadReplaceObj != null)
            {
                if(boomFx!=null)
                {
                    Destroy(Instantiate(boomFx, transform.position, transform.rotation), 3f);
                }
                Instantiate(deadReplaceObj, transform.position, transform.rotation);
                transform.position = new Vector3(3000, 3000, 3000);
                Destroy(gameObject,1f);
            }
        }
    }

    public void TakeDamage(int damage)
    {
        if(damage>hp)
        {
            hp = 0;
        }
        {
            hp -= damage;
        }
    }
}
